# Python函数参数传递机制
## Python函数参数的值传递机制
def swap(a, b):
    '''下面代码实现a、b变量的值交换'''
    a, b = b, a
    print("swap函数里，a =", a, "，b =", b)

a = 6
b = 9
swap(a, b)
print("函数外部，a =", a, "，b =", b)
print()

## Python函数参数的引用传递
def swap(dw):
    # 下面代码实现dw的a、b两个元素的值交换
    dw['a'], dw['b'] = dw['b'], dw['a']
    print("swap函数里，a =", dw['a'], "，b =", dw['b'])
    dw = None

dw = {"a": 6, "b": 9}
swap(dw)
print("外部 dw 字典中，a =", dw['a'], "，b =", dw['b'])
